package com.atcd.springboot2.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class uploadConfig implements WebMvcConfigurer {

    //环境隔离
    @Value("${file.staticPatternPath}")
    private  String staticPatternPath;
    @Value("${file.uploadFolder}")
    private String uploadFolder;


    //springmvc让开发者去配置<文件上传>的额外的静态资源服务路径(静态资源服务的映射)
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //                                 访问的目录                                  文件上传的目录
        registry.addResourceHandler(staticPatternPath).addResourceLocations("file:"+uploadFolder);
    }
}
